<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>练习flex</title>
    <style>
        .item{
            display: flex;
            display: -webkit-flex;
            flex-direction: row;
            justify-content: center;
        }
        .itemTitle{
            display: flex;
            flex-direction: column;
            width: 200px;
            height: 150px;
            padding: 20px;
        }
    </style>
</head>
<body>
    <div class="item" style="margin: 50px 0;">
        <img src="../img/Partner1.png" alt="" id="girlImg" style="width: 200px; height: 150px;">
        <p onclick="download()">下载</p>
    </div>
    <div class="main">
        <div class="item">
            <div class="itemTitle"><img src="../img/Partner1.png" alt=""></div>
            <div class="itemTitle"><img src="../img/Partner2.png" alt=""></div>
            <div class="itemTitle"><img src="../img/Partner3.png" alt=""></div>
            <div class="itemTitle"><img src="../img/Partner4.png" alt=""></div>
        </div>
        <div class="item">
            <div class="itemTitle"><img src="../img/Partner5.png" alt=""></div>
            <div class="itemTitle"><img src="../img/Partner6.png" alt=""></div>
            <div class="itemTitle"><img src="../img/Partner7.png" alt=""></div>
            <div class="itemTitle"><img src="../img/Partner8.png" alt=""></div>
        </div>
        <div class="item">
            <div class="itemTitle"><img src="../img/Partner9.png" alt=""></div>
            <div class="itemTitle"><img src="../img/Partner10.png" alt=""></div>
            <div class="itemTitle"><img src="../img/Partner11.png" alt=""></div>
            <div class="itemTitle"><img src="../img/Partner12.png" alt=""></div>
        </div>
    </div>
    <div style="width:300px;margin:0 auto; padding:20px 0;">
            <a target="_blank" href=" " style="display:inline-block;text-decoration:none;height:20px;line-height:20px;">< img src="" style="float:left;"/><p style="float:left;height:20px;line-height:20px;margin: 0px 0px 0px 5px; color:#939393;">京公网安备 11010802030232号</p ></ a>
    </div>
    <script>
        // function download(){
        //     console.log(11)
        //     let iframe = document.createElement('iframe');
        //     iframe.style.display = 'none';
        //     iframe.src='../img/Partner1.png';
        //     console.log(iframe.src)
        //     iframe.onload = function(){
        //         document.body.removeChild(iframe);
        //     }
        //     document.body.appendChild(iframe);
        // }
        function download(){
            var img = document.getElementById('girlImg'); // 获取要下载的图片
            var url = img.src;                            // 获取图片地址
            var a = document.createElement('a');         // 创建一个a节点插入的document
            var event = new MouseEvent('click')           // 模拟鼠标click点击事件
            a.download = 'beautifulGirl'                  // 设置a节点的download属性值
            a.href = url;                                 // 将图片的src赋值给a节点的href
            a.target="_blank"
            a.dispatchEvent(event)
        }
    </script>
</body>
</html>
